import pygame


class Sound:
    def __init__(self):
        """初始化音效"""
        # 加载背景音乐
        pygame.mixer_music.load("sound/background_music.mp3")
        # 循环播放
        pygame.mixer_music.play(-1)
        # 加载射击音效
        self.shooting_sound = pygame.mixer.Sound("sound/shoot.mp3")

    def play_shoot_sound(self):
        """播放射击音效"""
        pygame.mixer.Sound.play(self.shooting_sound)


if __name__ == '__main__':
    pygame.mixer.init()
    Sound().play_shoot_sound()
